package com.cx.bank.service.impl;

import com.cx.bank.mapper.UserMapper;
import com.cx.bank.pojo.UserBean;
import com.cx.bank.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RegisterImpl implements RegisterService {
    @Autowired
    UserMapper userMapper;

    @Override
    public boolean register(String userName, String password,int identity) {
        UserBean userBean = userMapper.findUserByName(userName);
        if (userBean==null){
            userBean = new UserBean(userName, password, identity);
            userBean.setUser_id(userMapper.userSum()+1);
            System.out.println(userBean);
//            userMapper.insertUser(userBean);
            return true;
        }else if (userBean.getUserName().equals(userName)){
            return false;
        }
        return false;
    }
}
